package com.candy.control;

import com.candy.bean.UserInfo;
import com.candy.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class LoginController {
    @Autowired
    LoginService loginService;

    @RequestMapping("/login")
    public String login(UserInfo userInfo){
//        调用业务逻辑层，检查用户名密码是否匹配
        boolean ok=loginService.login(userInfo);
        if(ok){
//            若用户名密码匹配，则跳转到登录成功页面
            return "welcome";
        }else {
//            反之返回登录页
            return "../../index";
        }


    }




}
